<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/11
 * Time: 16:36
 */

namespace App;


use Illuminate\Database\Eloquent\Model;

class Recruitment extends Model
{
    // 职位数组
    static public $post_array = [
        0 => '吧台长',
        1 => '督导',
        2 => '咖啡烘焙师',
        3 => '市场策划',
        4 => '销售员',
        5 => '咖啡培训师',
        6 => '西点面包师',
        7 => '简单厨师',
        8 => '咖啡师',
        9 => '咖啡学徒',
        10 => '店长'
    ];

    // 工资数组
    static public $salary_array = [
        0 => '2000元以下',
        1 => '2000-4000元',
        2 => '4000-6000元',
        3 => '6000-8000元',
        4 => '8000-10000元',
        5 => '12000元以上',
        6 => '面议'
    ];
    // 经验要求数组
    static public $experience_array = [
        0 => '1-2年',
        1 => '3-5年',
        2 => '5年以上',
        3 => '不限'
    ];

    // 性别要求数组
    static public $sex_array = [
        0 => '不限',
        1 => '男',
        2 => '女'
    ];

    // 表名称
    protected $table = 'recruitment';
    // 开启自动时间戳
    public $timestamps = true;
    // 日期都存储为时间戳
    protected $dateFormat = 'U';

    // 追加post_text字段
    public function getPostTextAttribute()
    {
        return self::$post_array[$this->attributes['post']];
    }

    // 追加salary_text字段
    public function getSalaryTextAttribute()
    {
        return self::$salary_array[$this->attributes['salary']];
    }

    // 追加experience_text字段
    public function getExperienceTextAttribute()
    {
        return self::$experience_array[$this->attributes['experience']];
    }

    // 追加sex_text字段
    public function getSexTextAttribute()
    {
        return self::$sex_array[$this->attributes['sex']];
    }

    public function cafe()
    {
        return $this->belongsTo('App\Cafe', 'cafe_id', 'id');
    }
}